package io.zouyalong.algo.leetcode;

/**
 * https://leetcode-cn.com/problems/palindrome-number/
 */
public class PalindromeNumber {
    public int reverseInt(int x) {
        int result = 0;
        while (x >= 10) {
            result = result * 10 + x%10;
            x /= 10;
        }
        result = result * 10 + x;
        return result;
    }

    public boolean isPalindrome(int x) {
        if (x < 0) {
            return false;
        }
        return x == reverseInt(x);
    }

    public static void main(String[] args) {
        var inst = new PalindromeNumber();
        System.out.printf("isPalindrome: %s\n", inst.isPalindrome(1));
    }
}
